--==================================================================== -- Utilities for dealing with server object packets --==================================================================== -- to check: -- get_smart_cover_data(se_cover) -- set_smart_cover_data(se_cover) --[[ Copyright (C) 2012 Alundaio This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License-]] --]] local stpk = net_packet() local uppk = net_packet() -- only use if you don't know the object class, otherwise call get_* directly to avoid needless overhead function get_object_data(sobj) if not (sobj) then return end local m_classes = { ["S_ACTOR"] = this.get_actor_data, ["AI_STL_S"] = this.get_stalker_data, --["AI_TRD_S"] = "cse_alife_trader", ["SM_BLOOD"] = this.get_monster_data, ["SM_BOARW"] = this.get_monster_data, ["SM_BURER"] = this.get_monster_data, ["SM_CAT_S"] = this.get_monster_data, ["SM_CHIMS"] = this.get_monster_data, ["SM_CONTR"] = this.get_monster_data, ["AI_CROW"] = this.get_abstract_data, -- could be wrong ["SM_DOG_S"] = this.get_monster_data, ["SM_FLESH"] = this.get_monster_data, ["SM_IZLOM"] = this.get_monster_data, ["SM_GIANT"] = this.get_monster_data, ["AI_PHANT"] = this.get_abstract_data, -- could be wrong ["SM_POLTR"] = this.get_monster_data, ["SM_P_DOG"] = this.get_monster_data, ["SM_DOG_P"] = this.get_monster_data, ["SM_DOG_F"] = this.get_monster_data, ["AI_RAT"] = this.get_monster_data, ["SM_SNORK"] = this.get_monster_data, ["SM_TUSHK"] = this.get_monster_data, ["SM_ZOMBI"] = this.get_monster_data, ["C_HLCP_S"] = this.get_heli_data, --["C_NIVA"] = "cse_alife_car", --["SCRPTCAR"] = "cse_alife_car", ["ARTEFACT"] = this.get_item_data, ["SCRPTART"] = this.get_item_data, --["AI_GRAPH"] = "cse_alife_graph_point", ["ON_OFF_S"] = this.get_squad_data, ["LVL_CHNG"] = this.get_level_changer_data, ["SCRIPTZN"] = this.get_space_restrictor_data, --["Z_TEAMBS"] = "cse_alife_team_base_zone", ["SPC_RS_S"] = this.get_space_restrictor_data, ["SMRT_C_S"] = this.get_smart_cover_data, --["SMRTTRRN"] = "se_smart_terrain", ["II_ATTCH"] = this.get_item_data, ["II_BTTCH"] = this.get_item_data, ["II_DOC"] = this.get_item_document_data, ["SO_HLAMP"] = this.get_lamp_data, ["O_HLAMP"] = this.get_lamp_data, --["O_SEARCH"] = "cse_alife_object_projector", ["TORCH_S"] = this.get_item_data, ["TORCH"] = this.get_item_data, --["O_BRKBL"] = "cse_alife_object_breakable", ["O_CLMBL"] = this.get_climable_data, ["O_PHYSIC"] = this.get_physic_data, ["O_DSTRBL"] = this.get_physic_data, ["O_PHYS_S"] = this.get_physic_data, ["O_DSTR_S"] = this.get_physic_data, --["P_SKELET"] = "cse_alife_ph_skeleton_object", ["S_INVBOX"] = this.get_inv_box_data, ["O_INVBOX"] = this.get_inv_box_data, ["DET_SIMP"] = this.get_item_data, ["DET_ADVA"] = this.get_item_data, ["DET_ELIT"] = this.get_item_data, ["DET_SCIE"] = this.get_item_data, ["E_STLK"] = this.get_item_data, ["E_HLMET"] = this.get_item_data, ["EQU_STLK"] = this.get_item_data, ["EQU_HLMET"] = this.get_item_data, ["II_BANDG"] = this.get_item_data, ["II_MEDKI"] = this.get_item_data, ["II_ANTIR"] = this.get_item_data, ["II_BOTTL"] = this.get_item_data, ["II_FOOD"] = this.get_item_data, ["S_FOOD"] = this.get_item_data, ["S_PDA"] = this.get_item_pda_data, ["D_PDA"] = this.get_item_pda_data, ["II_BOLT"] = this.get_item_data, ["WP_AK74"] = this.get_weapon_data, ["WP_ASHTG"] = this.get_weapon_data, ["WP_BINOC"] = this.get_weapon_data, ["WP_BM16"] = this.get_weapon_data, ["WP_GROZA"] = this.get_weapon_data, ["WP_HPSA"] = this.get_weapon_data, ["WP_KNIFE"] = this.get_weapon_data, ["WP_LR300"] = this.get_weapon_data, ["WP_PM"] = this.get_weapon_data, ["WP_RG6"] = this.get_weapon_data, ["WP_RPG7"] = this.get_weapon_data, ["WP_SVD"] = this.get_weapon_data, ["WP_SVU"] = this.get_weapon_data, ["WP_VAL"] = this.get_weapon_data, ["W_MOUNTD"] = this.get_weapon_data, ["W_STMGUN"] = this.get_weapon_data, ["S_EXPLO"] = this.get_item_data, ["II_EXPLO"] = this.get_item_data, ["AMMO"] = this.get_ammo_data, ["AMMO_S"] = this.get_ammo_data, ["S_OG7B"] = this.get_ammo_data, ["S_VOG25"] = this.get_ammo_data, ["S_M209"] = this.get_ammo_data, ["G_F1_S"] = this.get_item_data, ["G_RGD5_S"] = this.get_item_data, ["WP_SCOPE"] = this.get_item_data, ["WP_SILEN"] = this.get_item_data, ["WP_GLAUN"] = this.get_item_data, ["ZS_MBALD"] = this.get_anom_zone_data, ["ZS_GALAN"] = this.get_anom_zone_data, ["ZS_MINCE"] = this.get_anom_zone_data, ["ZS_RADIO"] = this.get_anom_zone_data, ["ZS_TORRD"] = this.get_anom_zone_data, ["Z_RUSTYH"] = this.get_visual_zone_data, ["ZS_BFUZZ"] = this.get_visual_zone_data, ["ZS_AMEBA"] = this.get_visual_zone_data, ["Z_MBALD"] = this.get_anom_zone_data, ["Z_RADIO"] = this.get_anom_zone_data, ["Z_CFIRE"] = this.get_anom_zone_data, ["Z_NOGRAV"] = this.get_anom_zone_data, ["Z_TORRID"] = this.get_anom_zone_data } local class = ini_sys:r_string_ex(sobj:section_name(),"class") if (class == nil or class == "") then return end return m_classes[class] and m_classes[class](sobj) or nil end function set_object_data(t,sobj) if not (sobj) then return end local m_classes = { ["S_ACTOR"] = this.set_actor_data, ["AI_STL_S"] = this.set_stalker_data, --["AI_TRD_S"] = "cse_alife_trader", ["SM_BLOOD"] = this.set_monster_data, ["SM_BOARW"] = this.set_monster_data, ["SM_BURER"] = this.set_monster_data, ["SM_CAT_S"] = this.set_monster_data, ["SM_CHIMS"] = this.set_monster_data, ["SM_CONTR"] = this.set_monster_data, ["AI_CROW"] = this.set_abstract_data, -- could be wrong ["SM_DOG_S"] = this.set_monster_data, ["SM_FLESH"] = this.set_monster_data, ["SM_IZLOM"] = this.set_monster_data, ["SM_GIANT"] = this.set_monster_data, ["AI_PHANT"] = this.set_abstract_data, -- could be wrong ["SM_POLTR"] = this.set_monster_data, ["SM_P_DOG"] = this.set_monster_data, ["SM_DOG_P"] = this.set_monster_data, ["SM_DOG_F"] = this.set_monster_data, ["AI_RAT"] = this.set_monster_data, ["SM_SNORK"] = this.set_monster_data, ["SM_TUSHK"] = this.set_monster_data, ["SM_ZOMBI"] = this.set_monster_data, ["C_HLCP_S"] = this.set_heli_data, --["SCRPTCAR"] = "cse_alife_car", ["ARTEFACT"] = this.set_item_data, ["SCRPTART"] = this.set_item_data, --["AI_GRAPH"] = "cse_alife_graph_point", ["ON_OFF_S"] = this.set_squad_data, ["LVL_CHNG"] = this.set_level_changer_data, ["SCRIPTZN"] = this.set_space_restrictor_data, --["Z_TEAMBS"] = "cse_alife_team_base_zone", ["SPC_RS_S"] = this.set_space_restrictor_data, ["SMRT_C_S"] = this.set_smart_cover_data, --["SMRTTRRN"] = "se_smart_terrain", ["II_ATTCH"] = this.set_item_data, ["II_BTTCH"] = this.set_item_data, ["II_DOC"] = this.set_item_document_data, ["SO_HLAMP"] = this.set_lamp_data, --["O_SEARCH"] = "cse_alife_object_projector", ["TORCH_S"] = this.set_item_data, --["O_BRKBL"] = "cse_alife_object_breakable", ["O_CLMBL"] = this.set_climable_data, ["O_PHYS_S"] = this.set_physic_data, ["O_DSTR_S"] = this.set_physic_data, --["P_SKELET"] = "cse_alife_ph_skeleton_object", ["S_INVBOX"] = this.set_inv_box_data, ["DET_SIMP"] = this.set_item_data, ["DET_ADVA"] = this.set_item_data, ["DET_ELIT"] = this.set_item_data, ["DET_SCIE"] = this.set_item_data, ["E_STLK"] = this.set_item_data, ["E_HLMET"] = this.set_item_data, ["II_BANDG"] = this.set_item_data, ["II_MEDKI"] = this.set_item_data, ["II_ANTIR"] = this.set_item_data, ["II_BOTTL"] = this.set_item_data, ["II_FOOD"] = this.set_item_data, ["S_FOOD"] = this.set_item_data, ["S_PDA"] = this.set_item_pda_data, ["D_PDA"] = this.set_item_pda_data, ["II_BOLT"] = this.set_item_data, ["WP_AK74"] = this.set_weapon_data, ["WP_ASHTG"] = this.set_weapon_data, ["WP_BINOC"] = this.set_weapon_data, ["WP_BM16"] = this.set_weapon_data, ["WP_GROZA"] = this.set_weapon_data, ["WP_HPSA"] = this.set_weapon_data, ["WP_KNIFE"] = this.set_weapon_data, ["WP_LR300"] = this.set_weapon_data, ["WP_PM"] = this.set_weapon_data, ["WP_RG6"] = this.set_weapon_data, ["WP_RPG7"] = this.set_weapon_data, ["WP_SVD"] = this.set_weapon_data, ["WP_SVU"] = this.set_weapon_data, ["WP_VAL"] = this.set_weapon_data, ["W_MOUNTD"] = this.set_weapon_data, ["W_STMGUN"] = this.set_weapon_data, ["S_EXPLO"] = this.set_item_data, ["AMMO_S"] = this.set_ammo_data, ["S_OG7B"] = this.set_ammo_data, ["S_VOG25"] = this.set_ammo_data, ["S_M209"] = this.set_ammo_data, ["G_F1_S"] = this.set_item_data, ["G_RGD5_S"] = this.set_item_data, ["WP_SCOPE"] = this.set_item_data, ["WP_SILEN"] = this.set_item_data, ["WP_GLAUN"] = this.set_item_data, ["ZS_MBALD"] = this.set_anom_zone_data, ["ZS_GALAN"] = this.set_anom_zone_data, ["ZS_MINCE"] = this.set_anom_zone_data, ["ZS_RADIO"] = this.set_anom_zone_data, ["ZS_TORRD"] = this.set_anom_zone_data, ["ZS_BFUZZ"] = this.set_anom_zone_data, ["Z_MBALD"] = this.set_anom_zone_data, ["Z_RADIO"] = this.set_anom_zone_data, ["Z_CFIRE"] = this.set_anom_zone_data, ["Z_NOGRAV"] = this.set_anom_zone_data, ["Z_TORRID"] = this.set_anom_zone_data } local class = ini_sys:r_string_ex(sobj:section_name(),"class") if (class == nil or class == "") then return end return m_classes[class] and m_classes[class](t,sobj) or nil end function get_abstract_data(stpk) -- if (stpk:r_eof()) then -- return -- end if (stpk:w_tell() <= 2) then return end local t = {} stpk:r_seek(0) t.dummy16 = stpk:r_u16() t.section_name = stpk:r_stringZ() t.name = stpk:r_stringZ() t.s_gameid = stpk:r_u8() t.s_rp = stpk:r_u8() t.position = stpk:r_vec3() t.direction = stpk:r_vec3() t.respawn_time = stpk:r_u16() t.object_id = stpk:r_u16() t.parent_id = stpk:r_u16() t.phantom_id = stpk:r_u16() t.s_flags = stpk:r_u16() t.version = stpk:r_u16() t.cse_abstract__unk1_h16 = stpk:r_u16() t.script_version = stpk:r_u16() t.unused = stpk:r_u16() if t.unused > 0 then t.extra = {} for i = 1, t.unused do t.extra[i] = stpk:r_u8() end end t.spawn_id = stpk:r_u16() t.extended_size = stpk:r_u16() return t end function set_abstract_data(t,stpk) stpk:w_begin(t.dummy16) stpk:w_stringZ(t.section_name) stpk:w_stringZ(t.name) stpk:w_u8(t.s_gameid) stpk:w_u8(t.s_rp) stpk:w_vec3(t.position) stpk:w_vec3(t.direction) stpk:w_u16(t.respawn_time) stpk:w_u16(t.object_id) stpk:w_u16(t.parent_id) stpk:w_u16(t.phantom_id) stpk:w_u16(t.s_flags) stpk:w_u16(t.version) stpk:w_u16(t.cse_abstract__unk1_h16) stpk:w_u16(t.script_version) stpk:w_u16(t.unused) if t.unused > 0 and t.extra ~= nil then for i = 1, t.unused do stpk:w_u8(t.extra[i]) end end stpk:w_u16(t.spawn_id) stpk:w_u16(t.extended_size) end function get_squad_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_alife_online_offline_group_properties_packet(t,stpk) return t end function set_squad_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_alife_online_offline_group_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_weapon_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_item_properties_packet(t,stpk) utils_stpk.parse_cse_alife_item_weapon_properties_packet(t,stpk) return t end function set_weapon_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_item_properties_packet(t,stpk) utils_stpk.fill_cse_alife_item_weapon_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_item_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_item_properties_packet(t,stpk) return t end function set_item_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_item_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_ammo_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_item_properties_packet(t,stpk) t.ammo_left = stpk:r_u16() return t end function set_ammo_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_item_properties_packet(t,stpk) stpk:w_u16(t.ammo_left) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_inv_box_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_inventory_box_properties_packet(t,stpk) return t end function set_inv_box_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_inventory_box_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_item_document_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_item_properties_packet(t,stpk) t.info_portion = stpk:r_stringZ() return t end function set_item_document_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_item_properties_packet(t,stpk) stpk:w_stringZ(t.info_portion) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_item_pda_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_item_properties_packet(t,stpk) t.original_owner = stpk:r_u16() t.specific_character = stpk:r_stringZ() t.info_portion = stpk:r_stringZ() return t end function set_item_pda_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_item_properties_packet(t,stpk) stpk:w_u16(t.original_owner) stpk:w_stringZ(t.specific_character) stpk:w_stringZ(t.info_portion) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_actor_data(sobj) if not (sobj) then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_creature_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_alife_trader_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.parse_cse_alife_creature_actor_properties_packet(t,stpk) utils_stpk.parse_se_actor_properties_packet(t,stpk) return t end function set_actor_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_creature_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_alife_trader_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.fill_cse_alife_creature_actor_properties_packet(t,stpk) utils_stpk.fill_se_actor_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_stalker_data(sobj) if not (sobj) then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_trader_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_creature_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_alife_monster_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_alife_human_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.parse_se_stalker_properties_packet(t,stpk) return t end function set_stalker_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_trader_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_creature_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_alife_monster_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_alife_human_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.fill_se_stalker_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_monster_data(sobj) if not (sobj) then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_creature_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_alife_monster_abstract_properties_packet(t,stpk) utils_stpk.parse_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.parse_se_monster_properties_packet(t,stpk) return t end function set_monster_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_creature_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_alife_monster_abstract_properties_packet(t,stpk) utils_stpk.fill_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.fill_se_monster_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_smart_cover_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_shape_properties_packet(t,stpk) utils_stpk.parse_cse_smart_cover_properties_packet(t,stpk) utils_stpk.parse_se_smart_cover_properties_packet(t,stpk) return t end function set_smart_cover_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_shape_properties_packet(t,stpk) utils_stpk.fill_cse_smart_cover_properties_packet(t,stpk) utils_stpk.fill_se_smart_cover_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function spawn_smart_cover(anm,sec,pos,lvid,gvid) local se_cover = alife_create(sec,pos,lvid,gvid) se_cover.last_description = anm se_cover.loopholes[anm] = 1 local data = get_smart_cover_data(se_cover) data.description = anm data.last_description = anm data.loopholes[anm] = 1 set_smart_cover_data(data,se_cover) return se_cover end function get_climable_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_shape_properties_packet(t,stpk) utils_stpk.parse_cse_alife_object_climable_properties_packet(t,stpk) return t end function set_climable_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_shape_properties_packet(t,stpk) utils_stpk.fill_cse_alife_object_climable_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_heli_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_motion_properties_packet(t,stpk) utils_stpk.parse_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.parse_cse_alife_helicopter_properties_packet(t,stpk) return t end function set_heli_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_motion_properties_packet(t,stpk) utils_stpk.fill_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.fill_cse_alife_helicopter_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function spawn_heli() local pos = db.actor:position() local se_obj = alife_create("helicopter",vector():set(pos.x,pos.y,pos.z),db.actor:level_vertex_id(),db.actor:game_vertex_id()) if (se_obj) then local data = get_heli_data(se_obj) if (data) then data.visual_name = [[dynamics\vehicles\mi2\veh_mi2_01]] data.motion_name = [[helicopter\aaa.anm]] data.startup_animation = "idle" data.skeleton_name = "idle" data.engine_sound = [[vehicles\helicopter\helicopter]] data.custom_data = "[logic]\n cfg = scripts\\heli.ltx" set_heli_data(data,se_obj) end end return se_obj end function get_lamp_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.parse_cse_alife_object_hanging_lamp_properties_packet(t,stpk) return t end function set_lamp_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.fill_cse_alife_object_hanging_lamp_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_physic_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.parse_cse_alife_object_physic_properties_packet(t,stpk) return t end function set_physic_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_ph_skeleton_properties_packet(t,stpk) utils_stpk.fill_cse_alife_object_physic_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_space_restrictor_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_shape_properties_packet(t,stpk) utils_stpk.parse_cse_alife_space_restrictor_properties_packet(t,stpk) return t end function set_space_restrictor_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_shape_properties_packet(t,stpk) utils_stpk.fill_cse_alife_space_restrictor_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_anom_zone_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_shape_properties_packet(t,stpk) utils_stpk.parse_cse_alife_space_restrictor_properties_packet(t,stpk) utils_stpk.parse_cse_alife_custom_zone_properties_packet(t,stpk) utils_stpk.parse_cse_alife_anomalous_zone_properties_packet(t,stpk) utils_stpk.parse_se_zone_anom_properties_packet(t,stpk) return t end function set_anom_zone_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_shape_properties_packet(t,stpk) utils_stpk.fill_cse_alife_space_restrictor_properties_packet(t,stpk) utils_stpk.fill_cse_alife_custom_zone_properties_packet(t,stpk) utils_stpk.fill_cse_alife_anomalous_zone_properties_packet(t,stpk) utils_stpk.fill_se_zone_anom_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_visual_zone_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_shape_properties_packet(t,stpk) utils_stpk.parse_cse_alife_space_restrictor_properties_packet(t,stpk) utils_stpk.parse_cse_alife_custom_zone_properties_packet(t,stpk) utils_stpk.parse_cse_alife_anomalous_zone_properties_packet(t,stpk) utils_stpk.parse_cse_visual_properties_packet(t,stpk) utils_stpk.parse_cse_alife_zone_visual_properties_packet(t,stpk) utils_stpk.parse_se_zone_visual_properties_packet(t,stpk) return t end function set_visual_zone_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_shape_properties_packet(t,stpk) utils_stpk.fill_cse_alife_space_restrictor_properties_packet(t,stpk) utils_stpk.fill_cse_alife_custom_zone_properties_packet(t,stpk) utils_stpk.fill_cse_alife_anomalous_zone_properties_packet(t,stpk) utils_stpk.fill_cse_visual_properties_packet(t,stpk) utils_stpk.fill_cse_alife_zone_visual_properties_packet(t,stpk) utils_stpk.fill_se_zone_visual_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_level_changer_data(sobj) if not sobj then return end stpk:w_begin(0) sobj:STATE_Write(stpk) stpk:r_seek(2) local t = {} utils_stpk.parse_cse_alife_object_properties_packet(t,stpk) utils_stpk.parse_cse_shape_properties_packet(t,stpk) utils_stpk.parse_cse_alife_space_restrictor_properties_packet(t,stpk) utils_stpk.parse_cse_alife_level_changer_properties_packet(t,stpk) utils_stpk.parse_se_level_changer_properties_packet(t,stpk) return t end function set_level_changer_data(t,sobj) if sobj then stpk:w_begin(0) utils_stpk.fill_cse_alife_object_properties_packet(t,stpk) utils_stpk.fill_cse_shape_properties_packet(t,stpk) utils_stpk.fill_cse_alife_space_restrictor_properties_packet(t,stpk) utils_stpk.fill_cse_alife_level_changer_properties_packet(t,stpk) utils_stpk.fill_se_level_changer_properties_packet(t,stpk) local size = stpk:w_tell() stpk:r_seek(2) sobj:STATE_Read(stpk,size) end end function get_item_update_data(sobj) if not sobj then return end uppk:w_begin(0) sobj:UPDATE_Write(uppk) if (uppk:r_eof()) then return end uppk:r_seek(2) local t = {} if data_left(uppk) then t.upd_num_items = uppk:r_u8() if (t.upd_num_items > 0) then t.upd_ph_force = read_chunk(uppk, 3, "s32") t.upd_ph_torque = read_chunk(uppk, 3, "s32") t.upd_ph_position = read_chunk(uppk, 3, "float") t.upd_ph_rotation = read_chunk(uppk, 4, "float") if bit_and(t.upd_num_items, 64) == 0 then if uppk:r_elapsed() >= 12 then t.upd_ph_angular_vel = read_chunk(uppk, 3, "float") else printf("cse_alife_item::update_read => cannot read 'upd:ph_angular_vel'") return end end if bit_and(t.upd_num_items, 128) == 0 then if uppk:r_elapsed() >= 12 then t.upd_ph_linear_vel = read_chunk(uppk, 3, "float") else printf("cse_alife_item::update_read => cannot read 'upd:ph_linear_vel'") return end end if data_left(uppk) then t.upd_cse_alife_item__marker_one = uppk:r_u8() end end if data_left(uppk) then t.upd_torch_flags = uppk:r_u8() end end return t end function set_item_update_data(t,sobj) if sobj then uppk:w_begin(0) if t.upd_num_items ~= nil then uppk:w_u8(t.upd_num_items) if t.upd_num_items ~= 0 then write_chunk(uppk, t.upd_ph_force, "s32") write_chunk(uppk, t.upd_ph_torque, "s32") write_chunk(uppk, t.upd_ph_position, "float") write_chunk(uppk, t.upd_ph_rotation, "float") write_chunk(uppk, t.upd_ph_angular_vel, "float") write_chunk(uppk, t.upd_ph_linear_vel, "float") if t.upd_cse_alife_item__marker_one ~= nil then uppk:w_u8(t.upd_cse_alife_item__marker_one) end end end if (t.upd_torch_flags) then uppk:w_u8(t.upd_torch_flags) end local size = uppk:w_tell() uppk:r_seek(2) sobj:UPDATE_Read(uppk,size) end end ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -- cse_abstract_properties function parse_cse_abstract_properties_packet(ret,stpk) t.dummy16 = stpk:r_u16() t.section_name = stpk:r_stringZ() t.name = stpk:r_stringZ() t.s_gameid = stpk:r_u8() t.s_rp = stpk:r_u8() t.position = stpk:r_vec3() t.direction = stpk:r_vec3() t.respawn_time = stpk:r_u16() t.object_id = stpk:r_u16() t.parent_id = stpk:r_u16() t.phantom_id = stpk:r_u16() t.s_flags = stpk:r_u16() t.version = stpk:r_u16() t.cse_abstract__unk1_h16 = stpk:r_u16() t.script_version = stpk:r_u16() t.unused = stpk:r_u16() if t.unused > 0 then t.extra = {} for i = 1, t.unused do t.extra[i] = stpk:r_u8() end end t.spawn_id = stpk:r_u16() t.extended_size = stpk:r_u16() return t end function fill_cse_abstract_properties_packet(ret,stpk) stpk:w_u16(ret.dummy16) stpk:w_stringZ(ret.section_name) stpk:w_stringZ(ret.name) stpk:w_u8(ret.s_gameid) stpk:w_u8(ret.s_rp) stpk:w_vec3(ret.position) stpk:w_vec3(ret.direction) stpk:w_u16(ret.respawn_time) stpk:w_u16(ret.object_id) stpk:w_u16(ret.parent_id) stpk:w_u16(ret.phantom_id) stpk:w_u16(ret.s_flags) stpk:w_u16(ret.version) stpk:w_u16(ret.cse_abstract__unk3_u16) stpk:w_u16(ret.script_version) stpk:w_u16(ret.unused) if (ret.unused > 0 and ret.extra ~= nil) then for i = 1, ret.unused do stpk:w_u8(ret.extra[i]) end end stpk:w_u16(ret.spawn_id) stpk:w_u16(ret.extended_size) end -- cse_alife_graph_point_properties function parse_cse_alife_graph_point_properties_packet(ret,stpk) ret.connection_point_name = stpk:r_stringZ() ret.connection_level_name = stpk:r_stringZ() ret.location0 = stpk:r_u8() ret.location1 = stpk:r_u8() ret.location2 = stpk:r_u8() ret.location3 = stpk:r_u8() return ret end function fill_cse_alife_graph_point_properties_packet(ret,stpk) stpk:w_stringZ(ret.connection_point_name) stpk:w_stringZ(ret.connection_level_name) stpk:w_u8(ret.location0) stpk:w_u8(ret.location1) stpk:w_u8(ret.location2) stpk:w_u8(ret.location3) end -- cse_shape_properties function parse_cse_shape_properties_packet(ret,stpk) local shape_count = stpk:r_u8() ret.shapes = {} if (shape_count > 0) then for i = 1, shape_count do local shape_type = stpk:r_u8() ret.shapes[i] = {} ret.shapes[i].shtype = shape_type if shape_type == 0 then -- sphere ret.shapes[i].offset = stpk:r_vec3() ret.shapes[i].radius = stpk:r_float() else -- box ret.shapes[i].v1 = stpk:r_vec3() ret.shapes[i].v2 = stpk:r_vec3() ret.shapes[i].v3 = stpk:r_vec3() ret.shapes[i].offset = stpk:r_vec3() end end end return ret end function fill_cse_shape_properties_packet(ret,stpk) local shape_count = table.getn(ret.shapes) stpk:w_u8(shape_count or 0) if (shape_count > 0) then for i = 1, shape_count do stpk:w_u8(ret.shapes[i].shtype) if ret.shapes[i].shtype == 0 then -- sphere stpk:w_vec3(ret.shapes[i].offset) stpk:w_float(ret.shapes[i].radius) else -- box stpk:w_vec3(ret.shapes[i].v1) stpk:w_vec3(ret.shapes[i].v2) stpk:w_vec3(ret.shapes[i].v3) stpk:w_vec3(ret.shapes[i].offset) end end end end -- cse_visual_properties function parse_cse_visual_properties_packet(ret,stpk) ret.visual_name = stpk:r_stringZ() ret.visual_flags = stpk:r_u8() return ret end function fill_cse_visual_properties_packet(ret,stpk) stpk:w_stringZ(ret.visual_name) stpk:w_u8(ret.visual_flags) end -- cse_motion_properties function parse_cse_motion_properties_packet(ret,stpk) ret.motion_name = stpk:r_stringZ() return ret end function fill_cse_motion_properties_packet(ret,stpk) stpk:w_stringZ(ret.motion_name) end -- cse_ph_skeleton_properties function parse_cse_ph_skeleton_properties_packet(ret,stpk) ret.skeleton_name = stpk:r_stringZ() ret.skeleton_flags = stpk:r_u8() ret.source_id = stpk:r_u16() return ret end function fill_cse_ph_skeleton_properties_packet(ret,stpk) stpk:w_stringZ(ret.skeleton_name) stpk:w_u8(ret.skeleton_flags) stpk:w_u16(ret.source_id) end --[[ local object_flags = { [1] = "flUseSwitches", [2] = "flSwitchOnline", [4] = "flSwitchOffline", [8] = "flInteractive", [16] = "flVisibleForAI", [32] = "flUsefulForAI", [64] = "flOfflineNoMove", [128] = "flUsedAI_Locations", [256] = "flUseGroupBehaviour", [512] = "flCanSave", [1024] = "flVisibleForMap", [2048] = "flUseSmartTerrains", [4096] = "flCheckForSeparator", [8192] = "flCorpseRemoval" } --]] -- cse_alife_object_properties function parse_cse_alife_object_properties_packet(ret,stpk) ret.game_vertex_id = stpk:r_u16() ret.distance = stpk:r_float() ret.direct_control = stpk:r_s32() ret.level_vertex_id = stpk:r_s32() ret.object_flags = stpk:r_s32() ret.custom_data = stpk:r_stringZ() ret.story_id = stpk:r_s32() ret.spawn_story_id = stpk:r_s32() return ret end function fill_cse_alife_object_properties_packet(ret,stpk) stpk:w_u16(ret.game_vertex_id) stpk:w_float(ret.distance) stpk:w_s32(ret.direct_control) stpk:w_s32(ret.level_vertex_id) stpk:w_s32(ret.object_flags) stpk:w_stringZ(ret.custom_data) stpk:w_s32(ret.story_id) stpk:w_s32(ret.spawn_story_id) end -- cse_alife_object_climable_properties function parse_cse_alife_object_climable_properties_packet(ret,stpk) ret.game_material = stpk:r_stringZ() return ret end function fill_cse_alife_object_climable_properties_packet(ret,stpk) stpk:w_stringZ(ret.game_material) end -- cse_smart_cover_properties function parse_cse_smart_cover_properties_packet(ret,stpk) ret.description = stpk:r_stringZ() ret.unk2_f32 = stpk:r_float() ret.enter_min_enemy_distance = stpk:r_float() ret.exit_min_enemy_distance = stpk:r_float() ret.is_combat_cover = stpk:r_u8() ret.can_fire = stpk:r_u8() end function fill_cse_smart_cover_properties_packet(ret,stpk) stpk:w_stringZ(ret.description) stpk:w_float(ret.unk2_f32) stpk:w_float(ret.enter_min_enemy_distance) stpk:w_float(ret.exit_min_enemy_distance) stpk:w_u8(ret.is_combat_cover) stpk:w_u8(ret.can_fire) end -- se_smart_cover_properties function parse_se_smart_cover_properties_packet(ret,stpk) if (data_left(stpk)) then local n = stpk:r_u8() for i = 1, n do local loophole_id = stpk:r_stringZ() local loophole_exist = stpk:r_bool() if not ret.loopholes then ret.loopholes = {} end ret.loopholes[loophole_id] = loophole_exist end end return ret end function fill_se_smart_cover_properties_packet(ret,stpk) stpk:w_stringZ(ret.last_description) local n = 0 for k,v in pairs (ret.loopholes) do n = n + 1 end stpk:w_u8(n) for k,v in pairs (ret.loopholes) do stpk:w_stringZ(k) stpk:w_bool(v) end end -- cse_alife_object_physic_properties function parse_cse_alife_object_physic_properties_packet(ret,stpk) ret.physic_type = stpk:r_s32() ret.mass = stpk:r_float() ret.fixed_bones = stpk:r_stringZ() return ret end function fill_cse_alife_object_physic_properties_packet(ret,stpk) stpk:w_s32(ret.physic_type) stpk:w_float(ret.mass) stpk:w_stringZ(ret.fixed_bones) end -- cse_alife_object_hanging_lamp_properties function parse_cse_alife_object_hanging_lamp_properties_packet(ret,stpk) ret.main_color = stpk:r_u32() ret.main_brightness = stpk:r_float() ret.main_color_animator = stpk:r_stringZ() ret.main_range = stpk:r_float() ret.light_flags = stpk:r_u16() ret.startup_animation = stpk:r_stringZ() ret.lamp_fixed_bones = stpk:r_stringZ() ret.health = stpk:r_float() ret.main_virtual_size = stpk:r_float() ret.ambient_radius = stpk:r_float() ret.ambient_power = stpk:r_float() ret.ambient_texture = stpk:r_stringZ() ret.main_texture = stpk:r_stringZ() ret.main_bone = stpk:r_stringZ() ret.main_cone_angle = stpk:r_float() ret.glow_texture = stpk:r_stringZ() ret.glow_radius = stpk:r_float() ret.ambient_bone = stpk:r_stringZ() ret.volumetric_quality = stpk:r_float() ret.volumetric_intensity = stpk:r_float() ret.volumetric_distance = stpk:r_float() return ret end function fill_cse_alife_object_hanging_lamp_properties_packet(ret,stpk) stpk:w_u32(ret.main_color) stpk:w_float(ret.main_brightness) stpk:w_stringZ(ret.main_color_animator) stpk:w_float(ret.main_range) stpk:w_u16(ret.light_flags) stpk:w_stringZ(ret.startup_animation) stpk:w_stringZ(ret.lamp_fixed_bones) stpk:w_float(ret.health) stpk:w_float(ret.main_virtual_size) stpk:w_float(ret.ambient_radius) stpk:w_float(ret.ambient_power) stpk:w_stringZ(ret.ambient_texture) stpk:w_stringZ(ret.main_texture) stpk:w_stringZ(ret.main_bone) stpk:w_float(ret.main_cone_angle) stpk:w_stringZ(ret.glow_texture) stpk:w_float(ret.glow_radius) stpk:w_stringZ(ret.ambient_bone) stpk:w_float(ret.volumetric_quality) stpk:w_float(ret.volumetric_intensity) stpk:w_float(ret.volumetric_distance) end -- cse_alife_inventory_box_properties function parse_cse_alife_inventory_box_properties_packet(ret,stpk) ret.unk1_u8 = stpk:r_u8() ret.unk2_u8 = stpk:r_u8() ret.tip = stpk:r_stringZ() return ret end function fill_cse_alife_inventory_box_properties_packet(ret,stpk) stpk:w_u8(ret.unk1_u8) stpk:w_u8(ret.unk2_u8) stpk:w_stringZ(ret.tip) end -- cse_alife_object_breakable_properties function parse_cse_alife_object_breakable_properties_packet(ret,stpk) ret.health = stpk:r_float() return ret end function fill_cse_alife_object_breakable_properties_packet(ret,stpk) stpk:w_float(ret.health) end -- cse_alife_helicopter_properties function parse_cse_alife_helicopter_properties_packet(ret,stpk) ret.startup_animation = stpk:r_stringZ() ret.engine_sound = stpk:r_stringZ() return ret end function fill_cse_alife_helicopter_properties_packet(ret,stpk) stpk:w_stringZ(ret.startup_animation or "idle") stpk:w_stringZ(ret.engine_sound) end -- cse_alife_creature_abstract_properties function parse_cse_alife_creature_abstract_properties_packet(ret,stpk) ret.g_team = stpk:r_u8() ret.g_squad = stpk:r_u8() ret.g_group = stpk:r_u8() ret.health = stpk:r_float() ret.dynamic_out_restrictions = read_chunk(stpk, stpk:r_s32(), "u16") ret.dynamic_in_restrictions = read_chunk(stpk, stpk:r_s32(), "u16") ret.killer_id = stpk:r_u16() ret.game_death_time = read_chunk(stpk, 8, "u8") return ret end function fill_cse_alife_creature_abstract_properties_packet(ret,stpk) stpk:w_u8(ret.g_team) stpk:w_u8(ret.g_squad) stpk:w_u8(ret.g_group) stpk:w_float(ret.health) stpk:w_s32(#ret.dynamic_out_restrictions) write_chunk(stpk, ret.dynamic_out_restrictions, "u16") stpk:w_s32(#ret.dynamic_in_restrictions) write_chunk(stpk, ret.dynamic_in_restrictions, "u16") stpk:w_u16(ret.killer_id) write_chunk(stpk, ret.game_death_time, "u8") end -- cse_alife_monster_abstract_properties function parse_cse_alife_monster_abstract_properties_packet(ret,stpk) ret.base_out_restrictors = stpk:r_stringZ() ret.base_in_restrictors = stpk:r_stringZ() ret.smart_terrain_id = stpk:r_u16() ret.smart_terrain_task_active = stpk:r_u8() return ret end function fill_cse_alife_monster_abstract_properties_packet(ret,stpk) stpk:w_stringZ(ret.base_out_restrictors) stpk:w_stringZ(ret.base_in_restrictors) stpk:w_u16(ret.smart_terrain_id) stpk:w_u8(ret.smart_terrain_task_active) end -- cse_alife_trader_abstract_properties function parse_cse_alife_trader_abstract_properties_packet(ret,stpk) ret.money = stpk:r_u32() ret.specific_character = stpk:r_stringZ() ret.trader_flags = stpk:r_s32() ret.character_profile = stpk:r_stringZ() ret.community_index = stpk:r_s32() ret.rank = stpk:r_s32() ret.reputation = stpk:r_s32() ret.character_name = stpk:r_stringZ() ret.dead_body_can_take = stpk:r_u8() ret.dead_body_closed = stpk:r_u8() return ret end function fill_cse_alife_trader_abstract_properties_packet(ret,stpk) stpk:w_u32(ret.money) stpk:w_stringZ(ret.specific_character) stpk:w_s32(ret.trader_flags) stpk:w_stringZ(ret.character_profile) stpk:w_s32(ret.community_index) stpk:w_s32(ret.rank) stpk:w_s32(ret.reputation) stpk:w_stringZ(ret.character_name) stpk:w_u8(ret.dead_body_can_take) stpk:w_u8(ret.dead_body_closed) end -- cse_alife_human_abstract_properties function parse_cse_alife_human_abstract_properties_packet(ret,stpk) ret.equipment_preferences = read_chunk(stpk, stpk:r_s32(), "u8") ret.weapon_preferences = read_chunk(stpk, stpk:r_s32(), "u8") end function fill_cse_alife_human_abstract_properties_packet(ret,stpk) stpk:w_s32(#ret.equipment_preferences) write_chunk(stpk, ret.equipment_preferences, "u8") stpk:w_s32(#ret.weapon_preferences) write_chunk(stpk, ret.weapon_preferences, "u8") end -- se_stalker_properties function parse_se_stalker_properties_packet(ret,stpk) if data_left(stpk) then ret.old_lvid = stpk:r_stringZ() ret.active_section = stpk:r_stringZ() ret.death_droped = stpk:r_bool() end return ret end function fill_se_stalker_properties_packet(ret,stpk) stpk:w_stringZ(ret.old_lvid) stpk:w_stringZ(ret.active_section) stpk:w_bool(ret.death_droped) end -- cse_alife_creature_actor_properties function parse_cse_alife_creature_actor_properties_packet(ret,stpk,upd) if (upd) then ret.upd_actor_state = stpk:r_u16() ret.upd_actor_accel_header = stpk:r_u16() ret.upd_actor_accel_data = stpk:r_s32() ret.upd_actor_velocity_header = stpk:r_u16() ret.upd_actor_velocity_data = stpk:r_s32() ret.upd_actor_radiation = stpk:r_float() ret.upd_actor_weapon = stpk:r_u8() ret.upd_num_items = stpk:r_u16() else ret.holder_id = stpk:r_u16() end return ret end function fill_cse_alife_creature_actor_properties_packet(ret,stpk,upd) if (upd) then stpk:w_u16(ret.upd_actor_state) stpk:w_u16(ret.upd_actor_accel_header) stpk:w_s32(ret.upd_actor_accel_data) stpk:w_u16(ret.upd_actor_velocity_header) stpk:w_s32(ret.upd_actor_velocity_data) stpk:w_float(ret.upd_actor_radiation) stpk:w_u8(ret.upd_actor_weapon) stpk:w_u16(ret.upd_num_items) else stpk:w_u16(ret.holder_id) end end -- se_actor_properties function parse_se_actor_properties_packet(ret,stpk) if data_left(stpk) then ret.start_position_filled = stpk:r_bool() ret.se_actor_save_marker = stpk:r_u16() end return ret end function fill_se_actor_properties_packet(ret,stpk) if ret.start_position_filled ~= nil then stpk:w_bool(ret.start_position_filled) stpk:w_u16(ret.se_actor_save_marker) end end -- cse_alife_monster_base_properties function parse_cse_alife_monster_base_properties_packet(ret,stpk) ret.spec_object_id = stpk:r_u16() return ret end function fill_cse_alife_monster_base_properties_packet(ret,stpk) stpk:w_u16(ret.spec_object_id) end -- se_monster_properties function parse_se_monster_properties_packet(ret,stpk) ret.off_level_vertex_id = stpk:r_stringZ() ret.active_section = stpk:r_stringZ() return ret end function fill_se_monster_properties_packet(ret,stpk) stpk:w_stringZ(ret.off_level_vertex_id) stpk:w_stringZ(ret.active_section) end -- cse_alife_monster_zombie_properties function parse_cse_alife_monster_zombie_properties_packet(ret,stpk) ret.field_of_view = stpk:r_float() ret.eye_range = stpk:r_float() ret.minimum_speed = stpk:r_float() ret.maximum_speed = stpk:r_float() ret.attack_speed = stpk:r_float() ret.pursuit_distance = stpk:r_float() ret.home_distance = stpk:r_float() ret.hit_power = stpk:r_float() ret.hit_interval = stpk:r_u16() ret.distance = stpk:r_float() ret.maximum_angle = stpk:r_float() end function fill_cse_alife_monster_zombie_properties_packet(ret,stpk) stpk:w_float(ret.field_of_view) stpk:w_float(ret.eye_range) stpk:w_float(ret.minimum_speed) stpk:w_float(ret.maximum_speed) stpk:w_float(ret.attack_speed) stpk:w_float(ret.pursuit_distance) stpk:w_float(ret.home_distance) stpk:w_float(ret.hit_power) stpk:w_u16(ret.hit_interval) stpk:w_float(ret.distance) stpk:w_float(ret.maximum_angle) end -- cse_alife_space_restrictor_properties function parse_cse_alife_space_restrictor_properties_packet(ret,stpk) --[[ [0] = "NONE default restrictor", [1] = "OUT default restrictor", [2] = "IN default restrictor", [3] = "NOT A restrictor" --]] ret.restrictor_type = stpk:r_u8() end function fill_cse_alife_space_restrictor_properties_packet(ret,stpk) stpk:w_u8(ret.restrictor_type) end -- se_anomaly_field_properties function parse_se_anomaly_field_properties_packet(ret,stpk) ret.initialized = stpk:r_u8() end function fill_se_anomaly_field_properties_packet(ret,stpk) stpk:w_u8(ret.initialized) end -- se_respawn_properties function parse_se_respawn_properties_packet(ret,stpk) if data_left(stpk) then ret.spawned_obj_count = stpk:r_u8() ret.spawned_obj_ids = read_chunk(stpk, ret.spawned_obj_count, "u16") end end function fill_se_respawn_properties_packet(ret,stpk) write_chunk(stpk, ret.spawned_obj_ids, "u16") end -- cse_alife_team_base_zone_properties function parse_cse_alife_team_base_zone_properties_packet(ret,stpk) ret.team = stpk:r_u8() end function fill_cse_alife_team_base_zone_properties_packet(ret,stpk) stpk:w_u8(ret.team) end -- cse_alife_level_changer_properties function parse_cse_alife_level_changer_properties_packet(ret,stpk) ret.dest_game_vertex_id = stpk:r_u16() ret.dest_level_vertex_id = stpk:r_s32() ret.dest_position = stpk:r_vec3() ret.dest_direction = stpk:r_vec3() ret.dest_level_name = stpk:r_stringZ() ret.dest_graph_point = stpk:r_stringZ() ret.silent_mode = stpk:r_u8() return ret end function fill_cse_alife_level_changer_properties_packet(ret,stpk) stpk:w_u16(ret.dest_game_vertex_id) stpk:w_s32(ret.dest_level_vertex_id) stpk:w_vec3(ret.dest_position) stpk:w_vec3(ret.dest_direction) stpk:w_stringZ(ret.dest_level_name) stpk:w_stringZ(ret.dest_graph_point) stpk:w_u8(ret.silent_mode) end -- se_level_changer_properties function parse_se_level_changer_properties_packet(ret,stpk) if (data_left(stpk)) then ret.enabled = stpk:r_bool() ret.hint = stpk:r_stringZ() ret.se_level_changer_save_marker = stpk:r_u16() end end function fill_se_level_changer_properties_packet(ret,stpk) stpk:w_bool(ret.enabled or true) stpk:w_stringZ(ret.hint or "") stpk:w_u16(ret.se_level_changer_save_marker or 0) end -- se_respawn_properties function parse_se_respawn_properties_packet(ret,stpk) end function fill_se_respawn_properties_packet(ret,stpk) write_chunk(stpk, ret.spawned_obj_ids, "u16") end -- cse_alife_custom_zone_properties function parse_cse_alife_custom_zone_properties_packet(ret,stpk) ret.max_power = stpk:r_float() ret.owner_id = stpk:r_s32() ret.enabled_time = stpk:r_s32() ret.disabled_time = stpk:r_s32() ret.start_time_shift = stpk:r_s32() end function fill_cse_alife_custom_zone_properties_packet(ret,stpk) stpk:w_float(ret.max_power) stpk:w_s32(ret.owner_id) stpk:w_s32(ret.enabled_time) stpk:w_s32(ret.disabled_time) stpk:w_s32(ret.start_time_shift) end -- cse_alife_anomalous_zone_properties function parse_cse_alife_anomalous_zone_properties_packet(ret,stpk) ret.offline_interactive_radius = stpk:r_float() ret.artefact_spawn_count = stpk:r_u16() ret.artefact_position_offset = stpk:r_s32() end function fill_cse_alife_anomalous_zone_properties_packet(ret,stpk) stpk:w_float(ret.offline_interactive_radius) stpk:w_u16(ret.artefact_spawn_count) stpk:w_s32(ret.artefact_position_offset) end -- se_zone_anom_properties function parse_se_zone_anom_properties_packet(ret,stpk) if data_left(stpk) then ret.last_spawn_time = stpk:r_u8() if ret.last_spawn_time == 1 then if data_left(stpk) then ret.c_time = utils_data.r_CTime(stpk) end end end end function fill_se_zone_anom_properties_packet(ret,stpk) if ret.last_spawn_time ~= nil then stpk:w_u8(ret.last_spawn_time) if ret.last_spawn_time == 1 then utils_data.w_CTime(stpk, ret.c_time) end else stpk:w_u8(0) end end -- cse_alife_zone_visual_properties function parse_cse_alife_zone_visual_properties_packet(ret,stpk) ret.idle_animation = stpk:r_stringZ() ret.attack_animation = stpk:r_stringZ() end function fill_cse_alife_zone_visual_properties_packet(ret,stpk) stpk:w_stringZ(ret.idle_animation or "idle") stpk:w_stringZ(ret.attack_animation or "blast") end -- se_zone_visual_properties function parse_se_zone_visual_properties_packet(ret,stpk) if data_left(stpk) then ret.last_spawn_time = stpk:r_u8() if ret.last_spawn_time == 1 then if data_left(stpk) then ret.c_time = utils_data.r_CTime(stpk) end end end end function fill_se_zone_visual_properties_packet(ret,stpk) if ret.last_spawn_time ~= nil then stpk:w_u8(ret.last_spawn_time) if ret.last_spawn_time == 1 then utils_data.w_CTime(stpk, ret.c_time) end else stpk:w_u8(0) end end -- cse_alife_online_offline_group_properties function parse_cse_alife_online_offline_group_properties_packet(ret,stpk) ret.members_count = stpk:r_s32() ret.members = read_chunk(stpk, ret.members_count, "u16") if data_left(stpk) then -- sim_squad_scripted: ret.current_target_id = stpk:r_stringZ() ret.respawn_point_id = stpk:r_stringZ() ret.respawn_point_prop_section = stpk:r_stringZ() ret.smart_id = stpk:r_stringZ() ret.sim_squad_scripted_save_marker = stpk:r_u16() end end function fill_cse_alife_online_offline_group_properties_packet(ret,stpk) stpk:w_s32(ret.members_count) write_chunk(stpk, ret.members, "u16") --if ret.current_target_id ~= nil then stpk:w_stringZ(ret.current_target_id or "nil") stpk:w_stringZ(ret.respawn_point_id or "nil") stpk:w_stringZ(ret.respawn_point_prop_section or "nil") stpk:w_stringZ(ret.smart_id or "nil") stpk:w_u16(ret.sim_squad_scripted_save_marker or 0) --end end -- cse_alife_item_properties function parse_cse_alife_item_properties_packet(ret,stpk) ret.condition = stpk:r_float() ret.upgrades = readvu32stringZ(stpk) end function fill_cse_alife_item_properties_packet(ret,stpk) stpk:w_float(ret.condition) writevu32stringZ(stpk,ret.upgrades) end -- cse_alife_item_weapon_properties function parse_cse_alife_item_weapon_properties_packet(ret,stpk) ret.ammo_current = stpk:r_u16() ret.ammo_elapsed = stpk:r_u16() ret.weapon_state = stpk:r_u8() ret.addon_flags = stpk:r_u8() ret.ammo_type = stpk:r_u8() ret.xz1 = stpk:r_u8() return ret end function fill_cse_alife_item_weapon_properties_packet(ret,stpk) stpk:w_u16(ret.ammo_current) stpk:w_u16(ret.ammo_elapsed) stpk:w_u8(ret.weapon_state) stpk:w_u8(ret.addon_flags) stpk:w_u8(ret.ammo_type) stpk:w_u8(ret.xz1) return ret end -- se_sim_faction_properties function parse_se_sim_faction_properties_packet(ret,stpk) if data_left(stpk) then ret.community_player = stpk:r_bool() ret.start_position_filled = stpk:r_bool() ret.current_expansion_level = stpk:r_u8() ret.last_spawn_time = utils_data.r_CTime(stpk) local tmp = nil local num = nil ret.squad_target_cache_count = stpk:r_u8() if ret.squad_target_cache_count > 0 then ret.squad_target_cache = {} for i = 1, ret.squad_target_cache_count do tmp = stpk:r_stringZ() num = stpk:r_u16() ret.squad_target_cache[tmp] = num end end ret.random_tasks_count = stpk:r_u8() if ret.random_tasks_count > 0 then ret.random_tasks = {} for i = 1, ret.random_tasks_count do tmp = stpk:r_u16() num = stpk:r_u16() ret.random_tasks[tmp] = num end end ret.current_attack_quantity_count = stpk:r_u8() if ret.current_attack_quantity_count > 0 then ret.current_attack_quantity = {} for i = 1, ret.current_attack_quantity_count do tmp = stpk:r_u16() num = stpk:r_u8() ret.current_attack_quantity[tmp] = num end end ret.squads_count = stpk:r_u16() if ret.squads_count > 0 then ret.init_squad_queue = {} for i = 1, ret.squads_count do local squad_id = stpk:r_stringZ() local settings_id = stpk:r_stringZ() local flag = stpk:r_bool() end end ret.se_sim_faction_save_marker = stpk:r_u16() end end function fill_se_sim_faction_properties_packet(ret,stpk) if ret.community_player ~= nil then stpk:w_bool(ret.community_player) stpk:w_bool(ret.start_position_filled) stpk:w_u8(ret.current_expansion_level) utils_data.w_CTime(stpk, ret.last_spawn_time) stpk:w_u8(ret.squad_target_cache_count) if ret.squad_target_cache ~= nil then for k, v in pairs(ret.squad_target_cache) do stpk:w_stringZ(k) stpk:w_u16(v) end end stpk:w_u8(ret.random_tasks_count) if ret.random_tasks ~= nil then for k, v in pairs(ret.random_tasks) do stpk:w_u16(k) stpk:w_u16(v) end end stpk:w_u8(ret.current_attack_quantity_count) if ret.current_attack_quantity ~= nil then for k, v in pairs(ret.current_attack_quantity) do stpk:w_u16(k) stpk:w_u8(v) end end stpk:w_u16(ret.squads_count) end end ------------------------------------------------------------------ ------------------------------------------------------------------ function data_left(stpk) return (stpk:r_elapsed() ~= 0) end function read_chunk(stpk, length, c_type) local tab = {} for i = 1, length do if c_type == "u8" then tab[i] = stpk:r_u8() elseif c_type == "u16" then tab[i] = stpk:r_u16() elseif c_type == "u32" then tab[i] = stpk:r_u32() elseif c_type == "s32" then tab[i] = stpk:r_s32() elseif c_type == "float" then tab[i] = stpk:r_float() elseif c_type == "string" then tab[i] = stpk:r_stringZ() elseif c_type == "bool" then tab[i] = stpk:r_bool() end end return tab end function write_chunk(stpk, tab, c_type) if tab == nil then return end for k, v in ipairs(tab) do if c_type == "u8" then stpk:w_u8(v) elseif c_type == "u16" then stpk:w_u16(v) elseif c_type == "u32" then stpk:w_u32(v) elseif c_type == "s32" then stpk:w_s32(v) elseif c_type == "float" then stpk:w_float(v) elseif c_type == "string" then stpk:w_stringZ(v) elseif c_type == "bool" then stpk:w_bool(v) end end end function readvu8uN(stpk,cnt) local v = {} for i=1,cnt do v[i] = stpk:r_u8() end return v end function writevu8uN(stpk,v) for i=1,#v,1 do stpk:w_u8(v[i]) end end function readvu32stringZ(stpk) local v = {} local cnt = stpk:r_s32() for i=1,cnt do v[i] = stpk:r_stringZ() end return v end function writevu32stringZ(pk,v) v = v or {} local len = #v pk:w_s32(len) for i=1,len do pk:w_stringZ(v[i]) end end